package vn.demand.dragon.model.business
{
	import mx.rpc.AsyncToken;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;

	public class LoadCustomerDetailsDelegate
	{
		private var responder : Function;
		private var failer : Function;
		private var service : HTTPService;

		public function LoadCustomerDetailsDelegate( responder : Function , failer : Function) 
		{
			// constructor will store a reference to the service we're going to call
			this.service = new HTTPService();
			this.service.url = "http://dev.dragon.com/index.php?m=quotations&a=quote_details&suppressHeaders=1";
//			this.service.url = "data/quote_details.xml";
			this.service.resultFormat = 'e4x';
			
			this.service.addEventListener(ResultEvent.RESULT, responder);
			this.service.addEventListener(FaultEvent.FAULT, failer);
		}

		public function loadCustomerService(customer_id:int) : void 
		{
			RIALogger.debug(this, "Load Customer Service");			
//			params.m = 'quotations';
//			params.a = 'quote_search';
//			params.suppressHeaders = '1';
			// call the service
			var token:AsyncToken = service.send({'customer_id': customer_id});
			
			// notify this responder when the service call completes
//			token.addResponder( responder );			
		}
	}
}